// JavaScript Document contains extra functions

// Function to adjust data values
// This function adjusts the value of numbers < 10
function adjustVal(x)
{
	if (x<10)
  {
  		x="0" + x;
  }
		return x;
}

// Function to get TimeStamp values (part of above function)
function getTS()
{
	// Standard object for date library function
	var d = new Date();
	
	// getting objects to reference hours, minutes and seconds
	var h = d.getHours();
	var m = d.getMinutes();
	var s = d.getSeconds();

	// getting objects to reference DD/MM/YY (instantaneous system date)
	var dd = d.getDate();
	var mm = d.getMonth();
	var yy = d.getYear();
	
	// the data returned by the system needs some adjusting
	yy = adjustVal(yy%100);
	h = adjustVal(h);
	m = adjustVal(m);
	s = adjustVal(s);
	mm=getRM(mm);

	// Putting all the above data in one single string to be returned
	var ts = dd+" "+mm+", "+yy+" @ "+h+":"+m+":"+s;
	return ts;
}

// The month code return by the system need to be converted into user readable data
function getRM(m)				// Converting Virtual Months to real months
{
	var s = null;
	switch (m)
	{
		case 0: s="Jan";
		break;
		case 1: s="Feb";
		break;
		case 2: s="Mar";
		break;
		case 3: s="Apr";
		break;
		case 4: s="May";
		break;
		case 5: s="Jun";
		break;
		case 6: s="Jul";
		break;
		case 7: s="Aug";
		break;
		case 8: s="Sep";
		break;
		case 9: s="Oct";
		break;
		case 10: s="Nov";
		break;
		case 11: s="Dec";
		break;
		default: s = alert("Error");
	}
	return s;
}
